<tc_include file="Public:head"/>
<div class="container" id="container">
    <div class="page">
        <div class="page__bd" style="height: 100%; overflow: hidden;">
            <div class="weui-tab">
                <div class="weui-tab__panel">

                    <div class="weui-tab" style="margin-top: 10px; height: auto;">

                        <!--details-box-->
                        <div class="details-box" style="overflow: hidden">
                            <div class="swiper-container">
                                <div class="discount"><span>{$coupon['coupon_name']}</span></div>
                                <!--幻灯片img-->
                                <div class="swiper-wrapper">
                                    <volist name="coupon['banners']" id="banner">
                                        <div class="swiper-slide"><img src="<php>echo '/'.C('UPLOADPATH').$banner['banner_img']</php>">
                                        </div>
                                    </volist>
                                </div>
                                <!--幻灯片img end-->
                                <!-- Add Pagination -->
                                <div class="swiper-pagination"></div>
                            </div>
                            <div class="details-info">
                                <p>{$coupon['title']}</p>
                                <span>{$coupon['exintegral']}<i class="icon iconfont icon-credit"></i></span>
                                <small>福利类型：优惠券</small>
                                <small>福利剩余：{$coupon['total_num']-$coupon['get_num']}件</small>
                                <small>使用限制：{$coupon['use_limit']}</small>
                                <a href="javascript:;" id="btn_exCoupon" class="weui-btn weui-btn_orange">兑 换</a>
                            </div>
                        </div>
                        <!--details-box end-->
                        <!--详细-->
                        <div class="gray-box">
                            <article class="weui-article">
                                <h1>{$coupon['title']}</h1>
                                <h6>{$coupon['title2']}</h6>
                            </article>
                            <div class="weui-cells acticle-list">
                                <div class="weui-cell">
                                    <div class="weui-cell__bd">
                                        <p><i class="icon iconfont icon-events"></i> <span>有效日期：{$coupon['end_date']|strtotime|date="m月d日",###}</span>
                                        </p>
                                    </div>
                                </div>
                                <div class="weui-cell">
                                    <div class="weui-cell__bd">
                                        <p><i class="icon iconfont icon-map"></i> <span>商铺地址：上海夏都小镇 － {$merchant['area']}</span>
                                        </p>
                                    </div>
                                </div>
                                <div class="weui-cell">
                                    <div class="weui-cell__bd">
                                        <p><i class="icon iconfont icon-quota"></i> <span>优惠限额：不限额</span></p>
                                    </div>
                                </div>
                            </div>
                            <div class="shop-box">
                                <a href="javascript:void(0);" class="weui-media-box weui-media-box_appmsg">
                                    <div class="weui-media-box__hd">
                                        <img class="weui-media-box__thumb"
                                             src="<php>echo '/'.C('UPLOADPATH').$merchant['logo']</php>" alt="">
                                    </div>
                                    <div class="weui-media-box__bd">
                                        <h3 class="weui-media-box__title"><font>福利提供：</font>{$merchant['name']}</h3>
                                        <p class="weui-media-box__time">
                                            品牌介绍：{$merchant['intro']}
                                        </p>
                                    </div>
                                </a>
                            </div>
                        </div>
                        <!--详细 end-->

                        <!--详情-->
                        <article class="weui-article" style="padding: 0;">
                            {$coupon['description']|htmlspecialchars_decode}
                        </article>
                        <!--详情 end-->
                    </div>
                </div>

                <tc_include file="Public:menu"/>
            </div>
        </div>
    </div>
</div>
<div id="dialogs">
    <!--BEGIN regDialog-->
    <div class="js_dialog" id="errDialog" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog notice-dialog">
            <div class="weui-dialog__btn">&times;</div>
            <div class="icon-box">
                <i class="icon iconfont icon-notice"></i>
            </div>
            <div class="weui-dialog__bd">
                <div class="weui-dialog__title">注册成功！</div>
                <p>欢迎加入夏都小镇，<font>即将跳转会员页面！</font></p>
            </div>
        </div>
    </div>
    <!--END regDialog-->
</div>
<tc_include file="Public:footer"/>
<script>

    function show_dialog(code, title, content) {
        if (code == 200) {
            $(".weui-dialog__bd .weui-dialog__title").html("兑换成功！");
            $(".weui-dialog__bd p").html("恭喜您，兑换成功");
        }
        else {
            $(".weui-dialog__bd .weui-dialog__title").html(title);
            $(".weui-dialog__bd p").html(content);
        }
        $('#errDialog').fadeIn(0);
    }
    //关闭dialogs
    $('#dialogs').on('click', '.weui-dialog__btn', function () {
        $(this).parents('.js_dialog').fadeOut(0);
    });

    $(function(){
        var swiper = new Swiper('.swiper-container', {
            pagination: '.swiper-pagination',
            slidesPerView: 1,
            paginationClickable: true,
            spaceBetween: 0,
            loop: true,
            autoplay : 2000
        });

        $("#btn_exCoupon").click(function () {
            $.post("{:U('Member/doExCoupon')}",{couponid:{$coupon["id"]}},function (data) {
                if(data.code == 200){
                    show_dialog(200);
                }else{
                    show_dialog(data.code,'兑换失败',data.message);
                }
            });
        });
    });
</script>